//隐藏
let dian=document.querySelector('.dian');
let allspan=document.querySelectorAll('span');

dian.onclick=function(){
    for(let i=0;i<allspan.length;i++)
if(allspan[i].style.color=="white")
allspan[i].style.color="black";
else
allspan[i].style.color="white";
}
   
//ul和li
let ul=document.querySelector("ul");
let li=document.querySelectorAll("li");
ul.addEventListener('click',(e)=>{
    console.log(e.target);
});

let change=document.querySelector(".change");
change.onclick=function(){
   for(var i=0;i<li.length;i++)
   {
       if(i%2==0){
           li[i].style.color="green";
        }
        else{
            li[i].style.color="red";
        }
   }
};
//ToDoList
let input=document.querySelector('input');
let addButton=document.querySelector('.addButton');

let myul=document.querySelector('.myul');
let removeButton=document.querySelector("ul li button")
   
addButton.onclick=function(){
    
  
    if(input.value){
        let myli=document.createElement('li');
        let button=document.createElement('button');
        let button_text=document.createTextNode("删除");    
        myli.innerHTML=input.value; 
        myul.appendChild(myli); 
        myli.appendChild(button);
        button.appendChild(button_text);
        
    }
    else 
    alert("请输入数据");
    }  
    
    myul.addEventListener('click',(e)=>{
        if(e.target.nodeName=="BUTTON"){
            myul.removeChild(e.target.parentElement);
        }
    });
    

 

    
    







